package cn.myra.equals;

public class Animal {
	//属性
	private String animalGender;
	private String animalType;
	private String animalFood;
	
	//行为方法
	
	public void eat() {
		System.out.println("i am eating"+animalFood);
	}
	
	public void play() {
		System.out.println("i am palying... ");
	}
	
	
	//重写方法
	
	
	
	
	
	
	
	@Override
	public boolean equals(Object obj) {
		
		if(this == obj) {
			return true;
		}
		if(obj instanceof Animal) {
			Animal obj1 = (Animal)obj;
			if(obj1.getAnimalGender().equals(this.getAnimalGender())
					&& obj1.getAnimalType().equals(this.getAnimalType())
					&& obj1.getAnimalFood().equals(this.getAnimalFood())) {
				return true;
			}
		}
		return false;
	}
	
	@Override
	public String toString() {
		return "动物类 [动物性别=" + animalGender + ", 动物种类=" + animalType + ", 动物食物=" + animalFood
				+ "]";
	}

	//构造方法
	public Animal() {
		super();
		// TODO Auto-generated constructor stub
	}
	

	public Animal(String animalGender, String animalType, String animalFood) {
		super();
		this.animalGender = animalGender;
		this.animalType = animalType;
		this.animalFood = animalFood;
	}


	//get&set
	public String getAnimalGender() {
		return animalGender;
	}

	public void setAnimalGender(String animalGender) {
		this.animalGender = animalGender;
	}
	public String getAnimalType() {
		return animalType;
	}
	public void setAnimalType(String animalType) {
		this.animalType = animalType;
	}
	public String getAnimalFood() {
		return animalFood;
	}
	public void setAnimalFood(String animalFood) {
		this.animalFood = animalFood;
	}

}
